package cn.sytton.taffe.web.sys.entity;

import cn.sytton.taffe.excel.annotation.ImportExcel;
import cn.sytton.taffe.framework.base.entity.BaseUpdatedEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import cn.sytton.taffe.framework.validation.Field;
import cn.sytton.taffe.framework.validation.NotDuplicate;

import javax.validation.constraints.*;

/**
 * 角色entity sys_role
 *
 * @author skyrock
 */
@Schema(description = "角色")
@Data
@EqualsAndHashCode(callSuper = true)
@NotDuplicate(value = {
        @Field(name = {"roleCode"}, message = "角色编号[ %s ]已存在"),
        @Field(name = {"roleName"}, message = "角色名字[ %s ]已存在")},
        excludeByField="roleId")
@TableName("sys_role")
public class RoleEntity extends BaseUpdatedEntity {

    @Schema(description = "角色ID")
    @TableId(type = IdType.ASSIGN_ID)
    private String roleId;    // 角色ID

    @Schema(description = "角色编号")
    @ImportExcel("角色编号")
    @NotNull(message = "角色编号不能为空")
    private String roleCode;    // 编号

    @Schema(description = "角色名称")
    @ImportExcel("角色名称")
    @NotNull(message = "角色名称不能为空")
    private String roleName;    // 名称

    @Schema(description = "角色类型: 系统级0/用户级1")
    @ImportExcel(value = "角色类型")
    private Integer roleType = 1;    // 类型, 0:系统级, 1:用户级

    @Schema(description = "角色状态, 禁用0/启用1")
    @ImportExcel(value = "角色状态")
    private Integer roleStatus = 1;    // 状态, 0:禁用, 1:启用 

    //-----以下是关联属性-----

    @Schema(description = "用户数量", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(exist = false)
    private Integer userCount = 0; //用户数量
}
